--for löve only!!

-- every gameelement is added here with Gameelement:New()

function love.load()

	dofile("engineLove.lua")
	gameelements = {}

  ---------------------------
	--[[ ANIMATIONSYSTEM ]]----
  ---------------------------
	dofile("lib/anal/AnAL.lua")
	
	-- array with animations that only play one
	-- TODO: what to do afterwards? timer?
	once_animations = {}

	-- load source
  img_explosion  = love.graphics.newImage("resources/explosion_sprite.png")
  img_blood  = love.graphics.newImage("resources/blood_sprite.png")

  ---------------------------
	--[[ SOUND-SYSTEM ]]-------
  ---------------------------
  sound_explosion_fire = love.audio.newSource("resources/explosion_fire.wav", "stream") -- the "static" tells LÖVE to load the file into memory, good for short sound effects, "stream" for directly playing files from hd (i used this, because only so multiple can be played at same time)
  meow = love.audio.newSource("resources/catmeow.wav", "stream") 
  ---------------------------
	--[[ globalfunctions ]]----
  ---------------------------
	dofile("globalfunc.lua")
	dofile('level.lua')

	-- classes !
	dofile('gameelement.lua')

	-----> EXPERIMENTAL
	dofile("abilities.lua")
	dofile("gameFunction.lua")
	dofile('menu.lua')
	--dofile('dialog.lua')

	dofile("test.lua")
	level.loadLevel(testmap)

end

-- -- -- -- -- -- -- -- -- --
-- -- MAINLOOP -- -- -- -- --
-- -- -- -- -- -- -- -- -- --

function love.update(dt)
	graphic.updateTexteffect()
	engine.controlsupdate()
	engine.clock.run()
	runStates()-- this is an temporary solution
	cleanPO()
	physic.movePO()
	checkStatus()

	physic.collisionDetection()	
	physic.uppdatePO()
	test.update(dt)

	-- run once playing animations
	engine.runOnceAnimations(dt)
end

function love.draw()		
	graphic.paintLayer1() --background
	graphic.paintLayer2() -- PO
	graphic.paintLayer3() -- onceAnimations & Ohts
	graphic.paintLayer4() -- GUI
	engine.paintOht()	
	test.paint()
end
